home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9203.ZIP / 80X87.ZIP / TESTFPU.H < prev    next >
Text File  |  1991-11-10  |  2KB  |  54 lines

  1. /* testfpu.h: header file for testpow.c, testsum.c, and testquad.c
  2.  * Copyright (C) 1991 by Nicholas Wilt.  All rights reserved.
  3.  */
  4.  
  5. /* This file contains external declarations and definitions of a
  6.  * few functions common to the three .c files.
  7.  *
  8.  * Function definitions don't normally belong in include files,
  9.  * but this header doesn't include anything intrinsic to the
  10.  * material demonstrated by the programs.
  11.  */
  12.  
  13. #include <math.h>
  14. #include <stdio.h>
  15. #include <dos.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18.  
  19. /* External declarations of the assembler functions. */
  20. extern double intpow(double x, unsigned int y);
  21. extern double sumarray(float *arr, int n);
  22. extern int solve_quadratic(double a, double b, double c,
  23.                double *x1, double *x2);
  24.  
  25. /* Routine to calculate the number of hundredths of seconds in
  26.    a given time structure. */
  27. long
  28. num_hunds(struct time *a)
  29. {
  30.   long hrs, mins, secs;
  31.   hrs = a->ti_hour * 360000L;
  32.   mins = a->ti_min * 6000L;
  33.   secs = a->ti_sec * 100L;
  34.   return(hrs + mins + secs + (long) a->ti_hund);
  35. }
  36.  
  37. /* Routine to calculate the number of hundredths of seconds
  38.    between two given time structures. */
  39. long
  40. diff_time(struct time *beg, struct time *end)
  41. {
  42.   return(num_hunds(end) - num_hunds(beg));
  43. }
  44.  
  45. /*  Returns % faster that the "fast"
  46.  *  time is compared to the "slow."
  47.  */
  48. int
  49. percent_diff(long dead, long fast, long slow)
  50. {
  51.   double diff = (double) (slow - dead) / (fast - dead);
  52.   return (int) (diff*100.0 - 100.0);
  53. }
  54.